<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title>${message(code: 'customer.nav.show')}</title>
</head>
<body>
<div class="nav">
  <span class="menuButton"><g:link class="list" action="list">${message(code: 'customer.nav.list')}</g:link></span>
  <span class="menuButton"><g:link class="create" action="create">${message(code: 'customer.nav.create')}</g:link></span>
</div>
<div class="body">
  <h1>${message(code: 'customer.nav.show')}</h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <div class="dialog">
    <table>
      <tbody>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.id')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'id')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.name')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'name')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.cardNumber')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'cardNumber')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.point')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'point')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.phone')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'handPhone')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.street')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'street')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.postal')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'postalCode')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.home.phone')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'homePhone')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.dob')}:</td>

        <td valign="top" class="value"><g:formatDate format="yyyy-MM-dd" date="${customerInstance.dob}"/></td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.job')}:</td>

        <td valign="top" style="text-align:left;" class="value">
          <ul>
            <g:each var="j" in="${jobs}">
              <g:if test="${j instanceof Pay}">
                <li><g:link controller="pay" action="show" id="${j.id}">${j?.encodeAsHTML()}</g:link></li>
              </g:if>
              <g:else>
                <li><g:link controller="job" action="show" id="${j.id}">${j?.encodeAsHTML()}</g:link></li>
              </g:else>
            </g:each>
          </ul>
          <g:link controller="job" params="['customer.id':customerInstance?.id]" action="create"><g:message code="customer.button.addjob"/></g:link>|
          <g:link controller="pay" params="['customer.id':customerInstance?.id]" action="create"><g:message code="customer.button.addpay"/></g:link>
        </td>

      </tr>


      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.membership')}:</td>

        <td valign="top" class="value"><g:link controller="membership" action="show" id="${customerInstance?.membership?.id}">${customerInstance?.membership?.encodeAsHTML()}</g:link></td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.balance')}:</td>

        <td valign="top" class="value"><ps:balance amount="${customerInstance.balance}"/></td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">${message(code: 'customer.table.remark')}:</td>

        <td valign="top" class="value">${fieldValue(bean: customerInstance, field: 'remark')}</td>

      </tr>

      <g:if test="${authUser != null}">
        <tr class="prop">
          <td valign="top" class="name">${message(code: 'customer.table.authuser')}:</td>
          <td valign="top" class="value"><g:link controller="authUser" action="show" id="${authUser?.id}">${authUser?.encodeAsHTML()}</g:link></td>
        </tr>
      </g:if>

      </tbody>
    </table>
  </div>
  <div class="buttons">
    <g:form>
      <input type="hidden" name="id" value="${customerInstance?.id}"/>
      <span class="button"><g:actionSubmit class="edit" value="${message(code: 'customer.nav.edit')}" action="edit"/></span>
      <g:if test="${authUser == null}">
        <span class="button"><g:link class="edit" params="['person.id':customerInstance?.id, 'authority.id':AuthRole.findByAuthority('ROLE_CUSTOMER').id]" controller="register" action="index">${message(code: 'common.button.register')}</g:link></span>
      </g:if>
      <span class="button"><g:actionSubmit class="delete" id="${customerInstance?.id}" onclick="return confirm('${message(code:'common.delete.confirm')}');" value="Delete"/></span>
    </g:form>
  </div>
</div>
</body>
</html>
